<template>
  <div class="raindropList">
    <div class="raindropTag">{{raindropItem.name}}</div>

    <div
      class="raindrop"
      @click='_handleGoRaindrop'
      :style="{backgroundImage:`url(${raindropItem.background_img})`}">
      <div v-if='isEmpty' class="catchMoment">
        <div class="comment">{{raindropItem.topic_num < 100 ? raindropItem.topic_num : '99+'}}</div>
        <div class="catch">{{raindropItem.is_catch <100 ? raindropItem.is_catch : '99+'}}</div>
      </div>
      <div v-if='isEmpty' class="pop"></div>
      <div v-if='!isEmpty && !isUid' class="meEmpty"></div>
      <div v-if='!isEmpty && isUid' class="otherEmpty">Empty</div>

    </div>

  </div>
</template>

<script>
  const Cookie = process.browser ? require('js-cookie') : undefined
  export default {
    data() {
      return {}
    },
    props: {
      raindropItem: {
        type: Object || Array,
        default() {
          return []
        }
      }
    },
    computed: {
      isEmpty() {
        return this.raindropItem.background_img
      },
      isUid() {
        return this.$route.params.uid
      }
    },
    mounted() {

    },
    methods: {
      _handleGoRaindrop() {
        const uid = this.isUid || Cookie.get('user')
        if (this.isEmpty) {
          this.$router.push({ path: `/raindrop/${uid}` })
        } else {
          console.log('000')
        }
      }
    }

  }
</script>
<style scoped lang="scss">
  div {
    height: auto;
    width: fit-content;
  }

  .raindropList {
    width: 350px;
    height: 352px;
    margin: 36px 0;
    padding-top: 84px;

    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;

    .raindrop {
      width: 316px;
      height: 316px;
      box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2), 2px -8px 32px 0px rgba(0, 0, 0, 0.5), 0px -6px 6px 0px rgba(255, 255, 255, 1);
      border-radius: 24px 200px 200px 200px;
      margin-top: -32px;
      background: url("") no-repeat center;
      -webkit-background-size: cover;
      background-size: cover;
      position: relative;

      .catchMoment {
        display: flex;
        flex-direction: column;
        margin: 20px 20px;
        color: #E6E6E6;
        font-size: 24px;

        div {
          padding-top: 26px;
          position: relative;

          &:after {
            content: '';
            position: absolute;
            width: 24px;
            height: 24px;
            left: 4px;
            top: 0;
            background: url("") no-repeat center;
            -webkit-background-size: cover;
            background-size: cover;
          }
        }

        .comment {
          &:after {
            background-image: url('../../assets/images/4.png');
          }
        }

        .catch {
          &:after {
            background-image: url('../../assets/images/9.png');
          }
        }

      }

      .pop {
        position: absolute;
        top: 0;
        left: 0;
        width: 150px;
        height: 100%;
        border-radius: 24px 0 0 200px;
        background: linear-gradient(90deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 100%);
      }

      .meEmpty {
        width: 100%;
        height: 100%;
        background: url("../../assets/images/10.png") no-repeat center;
        -webkit-background-size: 92px 78px;
        background-size: 92px 78px;
      }

      .otherEmpty {
        width: 100%;
        line-height: 316px;
        text-align: center;
      }
    }

    .raindropTag {
      max-width: 350px;
      margin-top: 24px;
      color: #4C4C4C;
      font-weight: 600;
      font-size: 34px;
      line-height: 44px;
      position: absolute;
      left: 22px;
      top: -40px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

  }
</style>
